/**
 * Created by lenovo-pc on 2017/9/15.
 */

$(document).ready(function () {
    var url = "fundFlow/getFundFlowListByUid";
    var userId = $("#ids").attr("class");
    $.get(url, {"userId": userId},
        function (data) {
            dataForView(data);
        }, "json");
})
function dataForView(data) {

    var content = $("#panel");
    content.empty();
    var rowsStart = "<div class='row'>";
    var rowsEnd = "</div>";
    var count = 0;
    content.append("<h5 class='page-header'></h5>");
    for (var i = 0; i < data.length; i++) {
        for (var key in data[i]) {
            //用来控制行的开始与结束
            if (count % 2 == 0) {
                if (count != 0) {
                    content.append(rowsEnd);
                }
                content.append(rowsStart);
            }
            //添加内容
            content.append("<div class='col-md-6'><label>" + names[key] + ":</label><span class='field'>" + enmuToStringForTradeType(data[i][key]) + "</span></div>");
            count++;
        }
        //添加水平线
        content.append("<h5 class='page-header'></h5>");
    }
    content.append(rowsEnd);


}

const names = {

    "fundTradeType": "类型",
    "fundCode": "基金代码",
    "orderNo": "订单号",
    "userId": "用户id",
    "id": "基金账户资产id",

    "note": "备注",
    "createTime": "创建时间",
    "fee": "手续费",
    "share": "份额",
    "amount": "金额",


}
/*交易类型,S:申购,R:赎回,A:定投,B:红利再投资....*/
function enmuToStringForTradeType(type) {
    var temp = '';
    switch (type) {
        case 'R':
            temp = "赎回";
            break;
        case 'S':
            temp = "申购";
            break
        case 'A':
            temp = "定投";
            break;
        case 'B':
            temp = "红利再投资";
            break;
        case 'P':
            temp = "认购";
            break;
        case 'PB':
            temp = "协议业务";
            break;
        case 'T':
            temp = "转换";
            break;
        case 'RF':
            temp = "快速赎回";
            break;
        default:
            temp = type;
            break;
    }
    return temp;
}